//
//  MembersViewController.m
//  随便点
//
//  Created by qfsoft on 15-3-10.
//  Copyright (c) 2015年 qfsoft. All rights reserved.
//

#import "MembersViewController.h"
#import "AppDelegate.h"
#import "ModifyViewController.h"
#import "messageViewController.h"
#import "goodsViewController.h"
#import "bindingViewController.h"
#import "passwordViewController.h"
#import "evaluationViewController.h"
#import "orderViewController.h"
#import "confirmViewController.h"

@interface MembersViewController (){
    NSMutableArray *array;
    UIButton *_button;
    NSDictionary *dic;
    AppDelegate *app;
}

@end

@implementation MembersViewController{
    NSMutableArray *tableViewArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
    dic = app.person;
    [self setupCell];
    //tableView 顶端不出现空白
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self xianshi];
    [self setupButton];
}
-(void)xianshi{
    self.phone.text = dic[@"id"];
    self.money.text  = [NSString stringWithFormat:@"%@",dic[@"money"]];
    self.mili.text  = [NSString stringWithFormat:@"%@",dic[@"points"]];
    app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
    app._id = self.phone.text;
    app.YuE = [NSString stringWithFormat:@"%@",dic[@"money"]];
    app._phone = [NSString stringWithFormat:@"%@",dic[@"tel"]];
}
-(void)setupCell{
    self.automaticallyAdjustsScrollViewInsets = NO;
    if (array == nil) {
        array = [NSMutableArray arrayWithObjects:@"全部订单",@"待确认",@"待评价",@"修改密码",@"绑定手机号码",@"收货地址管理",@"消息中心", nil];
    }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellIdentifier=@"cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if(cell==nil){
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.textLabel.text = array[indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.row) {
        case 0:{
            orderViewController *order = [self.storyboard instantiateViewControllerWithIdentifier:@"orderviewCV"];
            [self.navigationController pushViewController:order animated:YES];
        }
            break;
        case 1:{
            confirmViewController *confirm = [self.storyboard instantiateViewControllerWithIdentifier:@"confirmviewCV"];
            [self.navigationController pushViewController:confirm animated:YES];
        }
            break;
        case 2:{
            evaluationViewController *evaluation = [self.storyboard instantiateViewControllerWithIdentifier:@"evaluationviewCV"];
            [self.navigationController pushViewController:evaluation animated:YES];
        }
            break;
        case 3:{
            passwordViewController *password = [[passwordViewController alloc]init];
            [self.navigationController pushViewController:password animated:YES];
        }
            break;
        case 4:{
            bindingViewController *binding = [[bindingViewController alloc]init];
            [self.navigationController pushViewController:binding animated:YES];
        }
            break;
        case 5:{
            goodsViewController *goods = [self.storyboard instantiateViewControllerWithIdentifier:@"goodsVC"];
            [self.navigationController pushViewController:goods animated:YES];
        }
            break;
        case 6:{
            messageViewController *message = [self.storyboard instantiateViewControllerWithIdentifier:@"messageVC"];
            [self.navigationController pushViewController:message animated:YES];
        }
            break;
        default:
            break;
    }
}

-(void)setupButton{
    self.navigationItem.hidesBackButton = YES;
    UIBarButtonItem *shouye = [[UIBarButtonItem alloc]initWithTitle:@"首页" style:UIBarButtonItemStylePlain target:self action:@selector(pop)];
    
    self.navigationItem.leftBarButtonItem = shouye;
}
-(void)pop{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
